import 'reflect-metadata';
import { MappingMetadata,MAPPGING_KEY,CONTROLLER_KEY} from './_interface';

export function Mappging(method: "all" | "get" | "post" | "put" | "delete" | "patch" | "options" | "head", path?: string){
    return function(target: any, propertyKey: string, descriptor: PropertyDescriptor) {
        const existingMappings: MappingMetadata[] = Reflect.getMetadata(MAPPGING_KEY, target) || [];
        existingMappings.push({ method, path, handlerName: propertyKey });
        Reflect.defineMetadata(MAPPGING_KEY, existingMappings, target);
    };
}
export function Controller(path?: string) {
    return function(target: Function) {
      Reflect.defineMetadata(CONTROLLER_KEY, path, target);
    };
}